
<!--<div class="catalogue">-->
<!--    <ul class="nav nav-sidebar">-->
<!--        <li class="active"><a href="#">Overview <span class="sr-only">(current)</span></a></li>-->
<!--        <li><a href="#">Reports</a></li>-->
<!--        <li><a href="#">Analytics</a></li>-->
<!--        <li><a href="#">Export</a></li>-->
<!--        <li><a href="#">Reports</a></li>-->
<!--        <li><a href="#">Analytics</a></li>-->
<!--        <li><a href="#">Export</a></li>-->
<!--    </ul>-->
<!--</div>-->

<div class="catalogue" id="catalogue">
<ul class="nav nav-sidebar">

</ul>
</div>

<?php

use yii\web\View;

$js = <<<JS
function createCatalogue(){
    //给所有标题配好id，便于锚点定位
    var id = 1;
    $.each($('.content-body').find('h1,h2,h3,h4,h5,h6'),function(k,v){
        v.id = 'catalogue' + id++;
    });
    var catalogue = "";
    $.each($('.content-body').find('h1,h2,h3,h4,h5,h6'),function(k,v){
        catalogue = catalogue + "<li><a href='#" + v.id + "' class='" + v.tagName + "'>" + v.innerText + "</a></li>";
    });
    $(".catalogue ul").empty().append(catalogue);
}
JS;
//$this->view->registerJs($js, View::POS_READY, "catalogue-key");
Yii::$app->view->registerJs($js, View::POS_READY, "catalogue-key");
?>